using System;
using System.Collections.Generic;
using StructureMap;

namespace Nuwanda.TfsSpotlight.Shell.Services
{
    [Pluggable("MenuState")]
    public class MenuState : IMenuState
    {
        private readonly Dictionary<string, CommandConfiguration> _registeredCommands;

        public IEnumerable<CommandConfiguration> RegisteredCommands
        {
            get
            {
                foreach (var commandConfiguration in _registeredCommands.Values)
                {
                    yield return commandConfiguration;
                }
            }
        }

        public CommandConfiguration this[string command]
        {
            get { return this._registeredCommands[command]; }
        }

        public MenuState()
        {
            this._registeredCommands = new Dictionary<string, CommandConfiguration>();
        }

        public void Add(CommandConfiguration commandConfiguration)
        {
            this._registeredCommands.Add(commandConfiguration.Command, commandConfiguration);
        }

        public bool Contains(string commandName)
        {
            return this._registeredCommands.ContainsKey(commandName);
        }
    }
}